<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app;

class BaseModel extends \think\Model
{
    protected $name = "longbing";
    protected $type = ["create_time" => "int", "update_time" => "int", "delete_time" => "int", "deleted" => "int"];

    public function getRow($filter)
    {
        $filter["deleted"] = 0;
        $result = $this->where($filter)->find();
        if (!empty($result)) {
            $result = $result->toArray();
        }
        return $result;
    }

    public function listRow($filter)
    {
        $filter["deleted"] = 0;
        $result = $this->where($filter)->select();
        if (!empty($result)) {
            $result = $result->toArray();
        }
        return $result;
    }

    public function createRow($data)
    {
        if (!empty($data["create_time"])) {
            $data["create_time"] = time();
        }
        return $this->save($data);
    }

    public function createRows($datas)
    {
        return $this->saveAll($datas);
    }

    public function upsave($filter, $data)
    {
        $data["update_time"] = time();
        $result = $this->where($filter)->update($data);
        if (empty($result)) {
            return false;
        }
        return true;
    }

    public function updateRow($filter, $data)
    {
        $filter["deleted"] = 0;
        $data["update_time"] = time();
        $result = $this->where($filter)->update($data);
        if (empty($result)) {
            return false;
        }
        return true;
    }

    public function deleteRow($filter)
    {
        $filter["deleted"] = 0;
        $result = $this->updateRow($filter, ["delete_time" => time(), "deleted" => 1]);
        if (empty($result)) {
            return false;
        }
        return true;
    }

    public function destroyRow($filter)
    {
        $result = $this->where($filter)->delete();
        if (empty($result)) {
            return false;
        }
        return true;
    }
}

?>